﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using OLTS.DATA_SERVICE;
using OLTS.MODEL;

namespace ONTS.WEB.Service
{
    /// <summary>
    /// Summary description for GetProjectNameBySite
    /// </summary>
    public class GetProjectNameBySite : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            HttpRequest request = context.Request;
            HttpResponse response = context.Response;
            String val = "";
            var _cmd = new Project_Service();
            int idSite = Convert.ToInt16(request["idSite"]);
            foreach (OTS_PROJECT d in _cmd.GetProjectNameAllById(idSite))
            {
                if (val != "")
                    val += ";";

                val += d.ID + ":" + d.NAME;
            }           
            context.Response.ContentType = "text/html";
            context.Response.Write(new JavaScriptSerializer().Serialize(val));
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}